<template>
  <el-dialog title="编辑费用支出" width="40%" :before-close="dialogClose" :visible.sync="show">
    <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="支出项目">
          <el-input v-model="form.title" class="select_input"></el-input>
        </el-form-item>
        <el-form-item label="费用金额">
          <el-input v-model="form.price" class="select_input"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="add">确 定</el-button>
          <el-button @click="dialogClose">取 消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
</template>
 
<script>
export default {
  name: 'editCost',
  props:['show','form'],
  data() {
    return {
    }
  },
  created: function() {
    
  },
  methods: {
    dialogClose:function(){
      this.$emit("func",{'key':'editCost'})
    },
    add:function(){
      if(!this.form.title){
          this.$message.error('支出项目不能为空!');
          return;
      }
      if(!this.form.price){
          this.$message.error('费用金额不能为空!');
          return;
      }
      var that = this
      this.$post('pc/cost/save',this.form).then((res) => {
          if(res.code == 1){
            that.$message.success('修改成功!!');
            that.item = {}
            that.$emit("func",{'key':'editCost','type':1})
          }else{
            that.$message.error('修改失败!!!');
          }
      })
    }
  }
}
</script>